<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php echo $commander->getListCommandsPanel('sa-a-d-pager', ''); ?>
<div class="menu_list list-items">
    <table style="clear:both;" id="menulist" class="item_list" cellspacing="0" cellpadding="0" border="0">
        <thead class="fields">
            <tr>
                <th class="first center">&nbsp;&nbsp;Id&nbsp;&nbsp;</th>
                <th><?php echo ucfirst($txt->getWord('choose')); ?></th>
                <th><?php echo ucfirst($txt->getWord('title')); ?></th>
                <th><?php echo ucfirst($txt->getWord('import').' '.$txt->getWord('title')); ?></th>
                <th><?php echo ucfirst($txt->getWord('active')); ?></th>
                <th class="last"><?php echo ucfirst($txt->getWord('delete')); ?></th>
            </tr>
            <tr class="items">
                <td class="first center"><img 	title="<?php echo ucfirst($txt->getWord('new')); ?>"
                                                class="icon command" 
                                                src="<?php echo SYSICONS_URL; ?>add_16.gif" 
                                                onclick="if(document.getElementById('new_item_title').value != '') { edit_form.submit(); }" /></td>
                <td><input title="<?php echo ucfirst($txt->getWord('all')); ?>" class="select_all" type="checkbox" name="select_all" value="" /></td>
                <td><input class="small-m" name="new_cat_title" type="text" value="" maxlength="80" id="new_item_title" /></td>
                <td><input class="small-m" name="new_cat_title_import" type="text" value="" maxlength="50" /></td>
                <td colspan="6">&nbsp;</td>
                <td class="last"></td>
            </tr>
        </thead>
        <tbody><?php echo $commander->getComponentListLoading(); ?></tbody>
    </table>
    <input type="hidden" name="del_cat_id" id="del_cat_id" value="0" />
</div>
<script type="text/javascript">
function deleteDialog(itemId)
{
	jQuery('#delete_dialog').dialog('open');
	jQuery('#delete_dialog').dialog({
		bgiframe: true,
		resizable: false,
		height:140,
		modal: true,
		overlay: 
		{
			backgroundColor: '#000',
			opacity: 0.5
		},
		buttons: 
		{
			'<?php echo ucfirst($txt->getWord('no')); ?>': function() 
			{
				jQuery(this).dialog('close');
			},
			'<?php echo ucfirst($txt->getWord('delete')).' '.$txt->getWord('element'); ?>': function() 
			{
				jQuery('#del_cat_id').val(itemId);
				jQuery(this).dialog('close');
				jQuery('#edit_form').submit();
			}
		}
	});
}

jQuery(document).ready(function() 
{ 
	jQuery.ajax(
	{
		url: "ajax.php?con=<?php echo $_GET['con']; ?>&m=<?php echo $_GET['m']; ?>&editor=list&list=cat",
		cache: false,
	  	success: function(html)
	  	{ 
			jQuery('table.item_list tr.loading').remove();
			jQuery("table.item_list tbody").append(html); 
			jQuery("#menulist").addClass('tablesorter');
			jQuery("#menulist").tablesorter(
			{
				widthFixed: true,  
				headers: { 0: {sorter:"integer"}, 1: { sorter: false}, 5: {sorter: false} }, 
				//headers: { 1: {sorter:"currency"} }
				textExtraction: function(node) { if($(node).hasClass('first')) {return $(node).text(); } else { return node.innerHTML; } }
			}).tablesorterPager({container: jQuery("div.pager")});
		}
	});
});
</script>
<div id="delete_dialog" title="<?php echo ucfirst($txt->getWord('delete').' '.$txt->getWord('cat')); ?>?" style="display:none; text-align:left;">
	<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo ucfirst($txt->getWord('sure_you_want_to_delete')); ?></p>
</div>